/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.apt.Bean;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.upload.FormFile;
import org.apt.connectDB.MyConnect;

/**
 *
 * @author MinhThang
 */
public class create_author_lecture_bean extends org.apache.struts.action.ActionForm {
    
    private int lectureID;
    private String txtFullName;
    private String txtIDCard;
    private FormFile fileUpLoad;
    private String txtEmail;
    private String txtBirthday;
    private String txtMobile;
    private String txtAddress;
    private boolean status;
    private String description;
    private boolean gender;
    public create_author_lecture_bean() {
        super();
        // TODO Auto-generated constructor stub
    }
     public boolean CreateAuthor(){
         //Insert data to LectureAuthor table
        Connection conn=null;
        PreparedStatement ps=null;
        ResultSet rs=null;
        String sql="INSERT INTO [dbo].[LectureAuthor] ([FullName], [IDCard], [Image], [Email], [DOB], [MobilePhone], [Address], [Status], [Description], [Gender]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
         FormFile file=null;
        file=getFileUpLoad();
        try {
            conn=MyConnect.getConnection();
            ps=conn.prepareCall(sql);
            ps.setString(1, getTxtFullName());
            ps.setString(2, getTxtIDCard());
            ps.setString(3, file.getFileName());
            ps.setString(4, getTxtEmail());
            ps.setString(5, getTxtBirthday());
            ps.setString(6, getTxtMobile());
            ps.setString(7, getTxtAddress());
            ps.setBoolean(8, true);
            ps.setString(9, "");
            ps.setBoolean(10, isGender());
            ps.executeUpdate();
            return true;
         } catch (Exception e) {
             e.printStackTrace();
         }
         return false;
     }
    /**
     * @return the lectureID
     */
    public int getLectureID() {
        return lectureID;
    }

    /**
     * @param lectureID the lectureID to set
     */
    public void setLectureID(int lectureID) {
        this.lectureID = lectureID;
    }

    /**
     * @return the txtFullName
     */
    public String getTxtFullName() {
        return txtFullName;
    }

    /**
     * @param txtFullName the txtFullName to set
     */
    public void setTxtFullName(String txtFullName) {
        this.txtFullName = txtFullName;
    }

    /**
     * @return the txtIDCard
     */
    public String getTxtIDCard() {
        return txtIDCard;
    }

    /**
     * @param txtIDCard the txtIDCard to set
     */
    public void setTxtIDCard(String txtIDCard) {
        this.txtIDCard = txtIDCard;
    }

    /**
     * @return the fileUpLoad
     */
    public FormFile getFileUpLoad() {
        return fileUpLoad;
    }

    /**
     * @param fileUpLoad the fileUpLoad to set
     */
    public void setFileUpLoad(FormFile fileUpLoad) {
        this.fileUpLoad = fileUpLoad;
    }

    /**
     * @return the txtEmail
     */
    public String getTxtEmail() {
        return txtEmail;
    }

    /**
     * @param txtEmail the txtEmail to set
     */
    public void setTxtEmail(String txtEmail) {
        this.txtEmail = txtEmail;
    }

    /**
     * @return the txtBirthday
     */
    public String getTxtBirthday() {
        return txtBirthday;
    }

    /**
     * @param txtBirthday the txtBirthday to set
     */
    public void setTxtBirthday(String txtBirthday) {
        this.txtBirthday = txtBirthday;
    }

    /**
     * @return the txtMobile
     */
    public String getTxtMobile() {
        return txtMobile;
    }

    /**
     * @param txtMobile the txtMobile to set
     */
    public void setTxtMobile(String txtMobile) {
        this.txtMobile = txtMobile;
    }

    /**
     * @return the txtAddress
     */
    public String getTxtAddress() {
        return txtAddress;
    }

    /**
     * @param txtAddress the txtAddress to set
     */
    public void setTxtAddress(String txtAddress) {
        this.txtAddress = txtAddress;
    }

    /**
     * @return the status
     */
    public boolean isStatus() {
        return status;
    }

    /**
     * @param status the status to set
     */
    public void setStatus(boolean status) {
        this.status = status;
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

    /**
     * @param description the description to set
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * @return the gender
     */
    public boolean isGender() {
        return gender;
    }

    /**
     * @param gender the gender to set
     */
    public void setGender(boolean gender) {
        this.gender = gender;
    }

    /**
     * @return the ddlLecture
     */
    

    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */
   
}
